﻿using RBAC.Repository.RabbitInterfae;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using Traceability.Domain;
using Traceability.Service.Interfae;

namespace Traceability.Service.Impl
{
    public class RawService : IRawService
    {
        private readonly IRawRepository _rawRepository;
        public RawService(IRawRepository rawRepository)
        {
            _rawRepository=rawRepository;
        }
        /// <summary>
        /// 添加原料
        /// </summary>
        /// <param name="raw"></param>
        /// <returns></returns>
        public async Task<int> AddRaw(Raw raw)
        {
           return await _rawRepository.AddAsync(raw);
        }
        /// <summary>
        /// 反填原料信息
        /// </summary>
        /// <param name="RawId"></param>
        /// <returns></returns>
        public async Task<List<Raw>> GetRawdBy(string bath)
        {
         return  await _rawRepository.GetAsync(d =>d.Batch == bath);
          

        }
        /// <summary>
        /// 显示原料信息
        /// </summary>
        /// <param name="bacth"></param>
        /// <returns></returns>
        public async Task<List<Raw>> GetRawList(int rid)
        {
            return await _rawRepository.GetAsync(d => d.TraceabilityId==rid);
        }
        /// <summary>
        /// 修改原料信息
        /// </summary>
        /// <param name="raw"></param>
        /// <returns></returns>
        public async Task<int> UpdateRaw(Raw raw)
        {
           return await _rawRepository.UpdateAsync(raw);
        }
    }
}
